<?php

/**
 * SairController
 * 
 * @author
 * @version 
 */

require_once 'Zend/Controller/Action.php';

class SairController extends Zend_Controller_Action {
	/**
	 * The default action - show the home page
	 */
	public function indexAction() {
		$config = Zend_Registry::get ( 'config' );
		Zend_Auth::getInstance ()->clearIdentity ();
		$dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter ();
			
			$authAdapter = new Zend_Auth_Adapter_DbTable ( $dbAdapter, "usuarios", "login", "senha" );
			$authAdapter->setIdentity ( 'clear' );
			$authAdapter->setCredential ( 'not' );
			$result = Zend_Auth::getInstance()->authenticate($authAdapter);
		Zend_Auth::getInstance()->setStorage ( new Zend_Auth_Storage_Session ( $config->session->namespace ) );
			$usuario = $authAdapter->getResultRowObject ( null, "senha" );
			Zend_Auth::getInstance()->getStorage ()->write ( $usuario );
				
		$this->_redirect("./{$this->view->admindir}");
	}

}
